<script setup>
import { onMounted } from 'vue'
import { useUserStore } from './stores/user'

const userStore = useUserStore()

onMounted(() => {
  // 从localStorage恢复用户状态
  userStore.initFromStorage()
})
</script>

<template>
  <div id="app">
    <router-view />
  </div>
</template>

<style>
/* 全局样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background-color: #f5f7fa;
}

#app {
  height: 100vh;
  width: 100vw;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* 通用页面容器 */
.page-container {
  padding: 0;
  width: 100%;
  margin: 0;
  min-height: calc(100vh - 120px);
}

/* 响应式布局 */
@media (min-width: 1200px) {
  .page-container {
    padding: 0;
  }
}

@media (min-width: 1600px) {
  .page-container {
    padding: 0;
  }
}

/* 卡片样式优化 */
.el-card {
  border-radius: 8px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.el-card__header {
  padding: 16px 20px;
  border-bottom: 1px solid #ebeef5;
  background-color: #fafafa;
}

.el-card__body {
  padding: 20px;
}

/* 表格响应式 */
.el-table {
  width: 100%;
}

.el-table th {
  background-color: #f5f7fa;
  color: #606266;
  font-weight: 600;
}

/* 表单响应式 */
.el-form-item {
  margin-bottom: 20px;
}

.el-form-item__label {
  font-weight: 500;
  color: #606266;
}

/* 按钮样式优化 */
.el-button {
  border-radius: 6px;
  font-weight: 500;
}

.el-button--primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
}

.el-button--primary:hover {
  background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

/* 输入框样式 */
.el-input__inner {
  border-radius: 6px;
}

.el-select .el-input__inner {
  border-radius: 6px;
}

/* 分页器样式 */
.el-pagination {
  text-align: center;
  margin-top: 20px;
}

/* 空状态样式 */
.el-empty {
  padding: 40px 0;
}

.el-empty__description {
  color: #909399;
  font-size: 14px;
}

/* 布局组件样式 */
.layout-container {
  height: 100vh;
  display: flex;
}

.layout-sidebar {
  width: 240px;
  background: #304156;
  box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);
  z-index: 1000;
}

.layout-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.layout-header {
  height: 60px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 999;
}

.layout-content {
  flex: 1;
  overflow-y: auto;
  background: #f0f2f5;
}

/* 统计卡片样式 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stats-card {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  border-left: 4px solid #409eff;
}

.stats-card__title {
  font-size: 14px;
  color: #909399;
  margin-bottom: 8px;
}

.stats-card__value {
  font-size: 28px;
  font-weight: 600;
  color: #303133;
  margin-bottom: 4px;
}

.stats-card__trend {
  font-size: 12px;
  color: #67c23a;
}

/* 响应式网格 */
.responsive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

/* 搜索栏样式 */
.search-bar {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}

.search-bar .el-form {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.search-bar .el-form-item {
  margin-bottom: 0;
  flex: 1;
  min-width: 200px;
}

/* 操作按钮组 */
.action-buttons {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

/* 状态标签样式 */
.status-tag {
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 500;
}

.status-tag--success {
  background: #f0f9ff;
  color: #67c23a;
  border: 1px solid #b3e19d;
}

.status-tag--warning {
  background: #fdf6ec;
  color: #e6a23c;
  border: 1px solid #f5dab1;
}

.status-tag--danger {
  background: #fef0f0;
  color: #f56c6c;
  border: 1px solid #fbc4c4;
}

.status-tag--info {
  background: #f4f4f5;
  color: #909399;
  border: 1px solid #d3d4d6;
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* 动画效果 */
.fade-enter-active, .fade-leave-active {
  transition: opacity 0.3s ease;
}

.fade-enter-from, .fade-leave-to {
  opacity: 0;
}

/* 加载状态 */
.loading-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
}

/* 错误状态 */
.error-container {
  text-align: center;
  padding: 40px;
  color: #f56c6c;
}

/* 成功状态 */
.success-container {
  text-align: center;
  padding: 40px;
  color: #67c23a;
}

/* 退出登录对话框样式 */
.logout-dialog {
  display: flex;
  align-items: center;
  justify-content: center;
}

.logout-dialog .el-message-box {
  margin: 0 auto;
}
</style>
